package Inji;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JLabel;


import java.awt.Color;
import java.awt.Font;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.swing.JButton;

@SuppressWarnings("serial")
public class Output extends JPanel {
	
	private JScrollPane scrollPane;
	private JTextArea textArea;
	private JLabel lblNewLabel;
	private JLabel lblOutputDate;

	ArrayList<Data6> list;
	
	/**
	 * Create the panel.
	 */
	public Output() {
		setBackground(Color.ORANGE);
		setLayout(null);
		add(getScrollPane());
		add(getLblOutputDate());

	}
	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 59, 466, 259);
			scrollPane.setViewportView(getTextArea());
			scrollPane.setColumnHeaderView(getLblNewLabel());
		}
		return scrollPane;
	}
	private JTextArea getTextArea() {
		if (textArea == null) {
			textArea = new JTextArea();
			textArea.setFont(new Font("Monospaced", Font.PLAIN, 11));
		}
		return textArea;
	}
	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("이름        주소        연락처                    이메일                    나이        입사 날짜");
			lblNewLabel.setFont(new Font("굴림", Font.PLAIN, 11));
		}
		return lblNewLabel;
	}
	
	public void setD (ArrayList<Data6> list){
		this.list = list;
		
		textArea.setText("");
		for(int i=0;i<list.size();i++){
			
			System.out.println(i);
			textArea.append(list.get(i).name+"	");
			textArea.append(list.get(i).address+"	");
			textArea.append(list.get(i).phone+"		");
			textArea.append(list.get(i).email+"		");
			textArea.append(list.get(i).age+"	");
			
			SimpleDateFormat sb = new SimpleDateFormat("yy-MM-dd hh:mm");				
			String str = sb.format(list.get(i).nal);
			
			textArea.append(str+"");
			
			textArea.append("\n");
		}
	}
	private JLabel getLblOutputDate() {
		if (lblOutputDate == null) {
			lblOutputDate = new JLabel("            Output Date");
			lblOutputDate.setOpaque(true);
			lblOutputDate.setForeground(Color.WHITE);
			lblOutputDate.setFont(new Font("Consolas", Font.PLAIN, 17));
			lblOutputDate.setBackground(Color.DARK_GRAY);
			lblOutputDate.setBounds(258, 20, 220, 21);
		}
		return lblOutputDate;
	}
}
